import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_input_page.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_select_page.dart';
import 'package:enterprise_v6_app/app/core/values/colors.dart';
import 'package:enterprise_v6_app/app/modules/application/double_prevention_page/risk_control_page/risk_security_identification_page/risk_on_click_add_step_page/risk_on_click_add_step_page_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class RiskOnClickAddStepPagePage extends StatelessWidget {
  RiskOnClickAddStepPagePage({super.key});

  final controller = Get.put(RiskOnClickAddStepPageController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      init: controller,
      builder: (_) {
        return Scaffold(
          backgroundColor: AppColors.bg_color_grey,
          appBar: CustomAppBar(
            titleText:  controller.addAndUpdate ? '新增' : '编辑',
          ),
          body: SingleChildScrollView(
            child: Column(
              children: [
                Container(
                  margin: EdgeInsets.only(top: 10.w),
                  padding: EdgeInsets.only(left: 16.w, right: 20.w),
                  color: Colors.white,
                  child: Column(
                    children: [
                      CustomInputPage(
                        title: '管控措施描述：',
                        isRequired: true,
                        isEnabled: true,
                        text: controller.descriptionControlMeasures,
                        onCallBack: (value) {
                          controller.descriptionControlMeasures = value;
                        },
                      ),
                      CustomSelectPage(
                          isEnabled: true,
                          selectText: controller.controllerMeasuresName,
                          title: '管控手段',
                          hintText: '请选择',
                          onCallBack: () {
                            controller.selectHiddenDangerInvestigationTaskControlMeasuresType();

                          }),
                      CustomSelectPage(
                          isEnabled: true,
                          selectText: controller.hierarchControlMeasuresName,
                          title: '管控措施层级',
                          hintText: '请选择',
                          onCallBack: () {
                            controller.selectMeasureLevelType();

                          }),
                      CustomInputPage(
                        title: '隐患排查条目：',
                        isRequired: true,
                        isEnabled: true,
                        text: controller.hiddenDangerInvestigationItems,
                        onCallBack: (value) {
                          controller.hiddenDangerInvestigationItems = value;
                        },
                      ),
                      CustomSelectPage(
                          isEnabled: true,
                          selectText: controller.classificationControlMeasures1Name,
                          title: '管控措施分类1',
                          hintText: '请选择',
                          onCallBack: () {
                            controller.selectRiskControlClassificationOfControlMeasures1FirstType();
                          }),
                      Visibility(
                        visible: controller.isShow,
                        child: CustomSelectPage(
                            isEnabled: true,
                            selectText: controller.classificationControlMeasures2Name,
                            title: '管控措施分类2',
                            hintText: '请选择',
                            onCallBack: () {
                              controller.selectRiskControlClassificationOfControlMeasures1First2Type();
                            }),
                      ),
                      CustomInputPage(
                        title: ' 管控措施分类3：',
                        isRequired: false,
                        isEnabled: true,
                        text: controller.classificationControlMeasures3,
                        onCallBack: (value) {
                          controller.classificationControlMeasures3 = value;
                        },
                      ),
                      CustomInputPage(
                        title: '后果降低值',
                        isRequired: true,
                        textInputType: TextInputType.number,
                        isEnabled: true,
                        text: controller.consequenceReductionValue,
                        onCallBack: (value) {
                          controller.consequenceReductionValue = value;
                        },
                      ),
                      CustomInputPage(
                        title: '可能性降低值',
                        isRequired: true,
                        textInputType: TextInputType.number,
                        isEnabled: true,
                        text: controller.likelihoodReductionValue,
                        onCallBack: (value) {
                          controller.likelihoodReductionValue = value;
                        },
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          bottomSheet: Container(
            width: double.infinity,
            color: Colors.white,
            padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 5.w),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                SizedBox(
                  width: 120.w,
                  height: 40.w,
                  child: ElevatedButton(
                      style: ElevatedButton.styleFrom(
                          backgroundColor: const Color(0xffFFFFFF),
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(22.r),
                          ),
                          side: BorderSide(
                            color: const Color(0xff5C6DFF),
                            width: 1.w, // 设置边框线的宽度
                          )),
                      onPressed: Get.back,
                      child: Text(
                        '取消',
                        style: TextStyle(
                          fontSize: 14.sp,
                          color: const Color(0xff5C6DFF),
                          fontWeight: FontWeight.w400,
                        ),
                      )),
                ),
                SizedBox(
                  width: 202.w,
                  height: 40.w,
                  child: ElevatedButton(
                      style: ElevatedButton.styleFrom(
                        backgroundColor: AppColors.blue_button,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(22.r),
                        ),
                      ),
                      onPressed: controller.addRiskStep,
                      child: Text(
                        '确定',
                        style: TextStyle(
                          fontSize: 14.sp,
                          color: Colors.white,
                          fontWeight: FontWeight.w400,
                        ),
                      )),
                )
              ],
            ),
          ),
        );
      },
    );
  }
}
